import sequtils, algorithm, strutils

proc detectAnagrams*(word: string, candidates: seq[string]): seq[string] =
  let 
    self = word.toUpper
  candidates.filter do (it: string) -> bool:
    let candidate = it.toUpper
    candidate != self and (sorted candidate) == (sorted self)